﻿package com.shawnblais.ui
{
    import com.gskinner.motion.*;
    import fl.motion.easing.*;
    import flash.utils.*;
    import org.papervision3d.materials.*;
    import org.papervision3d.objects.*;
    import org.papervision3d.objects.primitives.*;
    import org.papervision3d.view.*;

    public class MainMenu3D extends BasicMenu3D
    {
        protected var _tipPlane:Plane;
        protected var _tipVisible:Boolean = false;
        protected var _tipClip:mcScrollTip;
        protected var _tip:DisplayObject3D;

        public function MainMenu3D(v3:Viewport3D, index:Number = -1, d:DisplayObject3D = null) : void
        {
            super(v3, index, d);
            return;
        }// end function

        protected function hideScrollTip()
        {
            if (this._tipVisible)
            {
                this._tipVisible = false;
                this._tipClip.text_txt.text = "NICE.";
                new GTween(this._tip, 3, {y:-3000}, {ease:Cubic.easeIn});
                new GTween(this._tip.container, 1, {alpha:0}, {ease:Cubic.easeIn});
            }
            return;
        }// end function

        override public function buildMenu(str:String, ary:Array) : void
        {
            super.buildMenu(str, ary);
            _headerMaterial.animated = true;
            if (!this._tipClip)
            {
                setTimeout(showScrollTip, 1000);
            }
            return;
        }// end function

        protected function showScrollTip():void
        {
            this._tipVisible = true;
            this._tipClip = new mcScrollTip();
            var _loc_1:* = new MovieMaterial(this._tipClip, true, true, true);
            _loc_1.doubleSided = false;
            _loc_1.smooth = true;
            _loc_1.interactive = true;
            _loc_1.animated = true;
            this._tipPlane = new Plane(_loc_1, this._tipClip.width, this._tipClip.height, numPlaneSegments, numPlaneSegments);
            this._tip = new DisplayObject3D();
            this._tipPlane.y = (-this._tipClip.height) / 2;
            this._tip.addChild(this._tipPlane);
            addChild(this._tip);
            this._tip.createViewportLayer(_viewport);
            this._tip.y = -140;
            this._tip.rotationX = -180;
            new GTween(this._tip, 1.5, {rotationX:0}, {ease:Bounce.easeOut});
            return;
        }// end function

        override public function next(param1:Boolean = false)
        {
            super.next(param1);
            if (param1)
            {
                this.hideScrollTip();
            }
            return;
        }// end function

        override public function previous(param1:Boolean = false)
        {
            super.previous(param1);
            if (param1)
            {
                this.hideScrollTip();
            }
            return;
        }// end function

    }
}
